import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:kiomax/utils/common_util.dart';
import '../../config/string_config.dart';
import '../../config/color_config.dart';
import '../../config/text_style_config.dart';
import '../../config/image_config.dart';
import '../../utils/screen_util.dart';
import 'login_page.dart';

class SplashPage extends StatefulWidget {
  const SplashPage({Key? key}) : super(key: key);

  @override
  State<SplashPage> createState() => _SplashPageState();
}

class _SplashPageState extends State<SplashPage> {
  @override
  void initState() {
    super.initState();
    // 页面构建完成之后执行
    WidgetsBinding.instance.addPostFrameCallback((_) {
      CommonUtil.showLocadingDialog(context);

      Future.delayed(Duration(seconds: 3), () {
        Navigator.pop(context); // 关闭 loading 弹窗
        // 如果你想跳转页面，也可以加下面这一句：
        Navigator.pushReplacement(context, MaterialPageRoute(builder: (context)=> const LoginPage()));
      });
    });
  }
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: ColorConfig.white,
      body: SafeArea(
        child: Padding(
          padding: EdgeInsets.fromLTRB(
            ScreenUtil.setWidth(25),
            ScreenUtil.setHeight(75),
            ScreenUtil.setWidth(25),
            ScreenUtil.setHeight(40),
          ),
          child: Column(
            mainAxisAlignment: MainAxisAlignment.start,
            crossAxisAlignment: CrossAxisAlignment.start,
            children: [
              Image.asset(
                ImageConfig.splashlogo2,
                width: ScreenUtil.getScreenWidth * 0.8,
                height: ScreenUtil.getScreenHeight * 0.2,
                fit: BoxFit.contain,
              ),
              Text(
                StringConfig.welcomeToKiomax,
                style: TextStyleConfig.heading20.copyWith(
                  fontSize: ScreenUtil.setSp(20),
                ),
                textAlign: TextAlign.center,
              ),
              SizedBox(height: ScreenUtil.setHeight(20)),
              Text(
                StringConfig.gettingThingsReady,
                style: TextStyleConfig.heading20.copyWith(
                  fontSize: ScreenUtil.setSp(20),
                ),
                textAlign: TextAlign.center,
              ),
            ],
          ),
        ),
      ),
    );
  }
}
